package com.woniu.product.controller;

import com.woniu.common.util.PageParam;
import com.woniu.common.util.ResponseData;
import com.woniu.product.pojo.TOrder;
import com.woniu.product.service.TOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ZhangYuQi
 * @Description
 */
@RestController
public class OrderController {

    @Autowired
    private TOrderService orderService;

    /**
     * 根据订单编号查订单
     */
    @GetMapping("/queryOrderByOrderNum")
    public ResponseData<?> queryOrderByOrderNum(@RequestParam("orderNum") String orderNum){
        return orderService.queryOrderByOrderNum(orderNum);
    }

    /**
     * 查询当前登录人所有订单
     */
    @PostMapping("/queryAllOrder")
    public ResponseData<?> queryAllOrder(@RequestBody PageParam<TOrder> pageParam){
        return orderService.queryAllOrder(pageParam);
    }

    /**
     * 修改发票状态
     */
    @GetMapping("/updateIsInvoiceStatus")
    public ResponseData<?> updateIsInvoiceStatus(@RequestParam("orderNum") String orderNum){
        return orderService.updateIsInvoiceStatus(orderNum);
    }

    /**
     * 添加订单数据
     */
    @PostMapping("/addOrder")
    private void addOrder(TOrder order) {
        orderService.save(order);
    }

    /**
     * 修改订单状态
     */
    @GetMapping("/updateStatus")
    private ResponseData<?> updateStatus(String orderNum){
        return orderService.updateStatus(orderNum);
    }


}
